import requests

from apicore.OrderRequest import orderRequest


class addressApi(orderRequest):
    def address(self, token, *args):
        uri = '/api/front/address/edit'
        data = {
            "realName": args[0][0],
            "phone": args[0][1],
            "detail": args[0][2],
            "id": args[0][3],
            "address": {
                "province": args[0][4],
                "city": args[0][5],
                "district": args[0][6],
                "cityId": args[0][7]
            },
            "isDefault": args[0][8]
        }
        headers = {  # 修改这里
            "Content-Type": "application/json",
            "authori-zation": token
        }
        response = self.send_request('POST',uri,headers,json=data)
        if response.status_code == 200:
            return response
        else:
            return None
